/**
 * <copyright>
 * </copyright>
 *

 */
package info.unlp.tesis.qvtoperational.impl;

import info.unlp.tesis.qvtoperational.EntryOperation;
import info.unlp.tesis.qvtoperational.ModelParameter;
import info.unlp.tesis.qvtoperational.ModelType;
import info.unlp.tesis.qvtoperational.OperationalTransformation;
import info.unlp.tesis.qvtoperational.QvtoperationalPackage;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Operational Transformation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link info.unlp.tesis.qvtoperational.impl.OperationalTransformationImpl#getModelType <em>Model Type</em>}</li>
 *   <li>{@link info.unlp.tesis.qvtoperational.impl.OperationalTransformationImpl#getName <em>Name</em>}</li>
 *   <li>{@link info.unlp.tesis.qvtoperational.impl.OperationalTransformationImpl#getModelParameter <em>Model Parameter</em>}</li>
 *   <li>{@link info.unlp.tesis.qvtoperational.impl.OperationalTransformationImpl#getOwnedOperation <em>Owned Operation</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class OperationalTransformationImpl extends MinimalEObjectImpl.Container implements OperationalTransformation
{
  /**
   * The cached value of the '{@link #getModelType() <em>Model Type</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getModelType()
   * @generated
   * @ordered
   */
  protected EList<ModelType> modelType;

  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getModelParameter() <em>Model Parameter</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getModelParameter()
   * @generated
   * @ordered
   */
  protected EList<ModelParameter> modelParameter;

  /**
   * The cached value of the '{@link #getOwnedOperation() <em>Owned Operation</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getOwnedOperation()
   * @generated
   * @ordered
   */
  protected EntryOperation ownedOperation;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected OperationalTransformationImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return QvtoperationalPackage.Literals.OPERATIONAL_TRANSFORMATION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ModelType> getModelType()
  {
    if (modelType == null)
    {
      modelType = new EObjectContainmentEList<ModelType>(ModelType.class, this, QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__MODEL_TYPE);
    }
    return modelType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ModelParameter> getModelParameter()
  {
    if (modelParameter == null)
    {
      modelParameter = new EObjectContainmentEList<ModelParameter>(ModelParameter.class, this, QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__MODEL_PARAMETER);
    }
    return modelParameter;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EntryOperation getOwnedOperation()
  {
    return ownedOperation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetOwnedOperation(EntryOperation newOwnedOperation, NotificationChain msgs)
  {
    EntryOperation oldOwnedOperation = ownedOperation;
    ownedOperation = newOwnedOperation;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__OWNED_OPERATION, oldOwnedOperation, newOwnedOperation);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setOwnedOperation(EntryOperation newOwnedOperation)
  {
    if (newOwnedOperation != ownedOperation)
    {
      NotificationChain msgs = null;
      if (ownedOperation != null)
        msgs = ((InternalEObject)ownedOperation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__OWNED_OPERATION, null, msgs);
      if (newOwnedOperation != null)
        msgs = ((InternalEObject)newOwnedOperation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__OWNED_OPERATION, null, msgs);
      msgs = basicSetOwnedOperation(newOwnedOperation, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__OWNED_OPERATION, newOwnedOperation, newOwnedOperation));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__MODEL_TYPE:
        return ((InternalEList<?>)getModelType()).basicRemove(otherEnd, msgs);
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__MODEL_PARAMETER:
        return ((InternalEList<?>)getModelParameter()).basicRemove(otherEnd, msgs);
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__OWNED_OPERATION:
        return basicSetOwnedOperation(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__MODEL_TYPE:
        return getModelType();
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__NAME:
        return getName();
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__MODEL_PARAMETER:
        return getModelParameter();
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__OWNED_OPERATION:
        return getOwnedOperation();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__MODEL_TYPE:
        getModelType().clear();
        getModelType().addAll((Collection<? extends ModelType>)newValue);
        return;
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__NAME:
        setName((String)newValue);
        return;
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__MODEL_PARAMETER:
        getModelParameter().clear();
        getModelParameter().addAll((Collection<? extends ModelParameter>)newValue);
        return;
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__OWNED_OPERATION:
        setOwnedOperation((EntryOperation)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__MODEL_TYPE:
        getModelType().clear();
        return;
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__NAME:
        setName(NAME_EDEFAULT);
        return;
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__MODEL_PARAMETER:
        getModelParameter().clear();
        return;
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__OWNED_OPERATION:
        setOwnedOperation((EntryOperation)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__MODEL_TYPE:
        return modelType != null && !modelType.isEmpty();
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__MODEL_PARAMETER:
        return modelParameter != null && !modelParameter.isEmpty();
      case QvtoperationalPackage.OPERATIONAL_TRANSFORMATION__OWNED_OPERATION:
        return ownedOperation != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(')');
    return result.toString();
  }

} //OperationalTransformationImpl
